package com.newasia.search.converter;

import com.newasia.search.dal.entitys.SkuKey;
import com.newasia.search.dal.entitys.SpuKey;
import com.newasia.search.dto.SkuDto;
import com.newasia.search.dto.SpuDto;
import com.newasia.search.entity.SkuDocument;
import com.newasia.search.entity.SpuDocument;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * 腾讯课堂搜索【咕泡学院】
 * 官网：www.gupaoedu.com
 * 风骚的Mic 老师
 * create-date: 2019/7/24-19:15
 */
@Mapper(componentModel = "spring")
public interface ProductConverter {

    @Mappings({})
    SpuDto spu2Dto(SpuDocument item);

    List<SpuDto> spu2Dto(List<SpuDocument> items);

    @Mappings({})
    SkuDto sku2Dto(SkuDocument item);

    List<SkuDto> skuDto(List<SkuDocument> items);

    @Mappings({
            @Mapping(source = "spu_id",target = "spuId"),
            @Mapping(source = "brand_name",target = "brandName"),
            @Mapping(source = "cat_name",target = "catName"),
            @Mapping(source = "title",target = "title"),
            @Mapping(source = "spu_key",target = "spuKey"),
            @Mapping(source = "price",target = "price")
    })
    SpuDocument spu2Document(SpuKey spuKey);

    @Mappings({
            @Mapping(source = "spu_id",target = "spuId"),
            @Mapping(source = "sku_id",target = "skuId"),
            @Mapping(source = "sku_image",target = "skuImage"),
            @Mapping(source = "sku_key",target = "skuKey")
    })
    SkuDocument sku2Document(SkuKey skuKey);
}
